
## This module should lay in PYTHONPATH 

import win32service
import win32serviceutil
import win32api
#import win32con


class TestService(win32serviceutil.ServiceFramework):
	_svc_name_ = "_test service"
	_svc_display_name_ = " service - It Does nothing " ## this actualy goes in name field ..

	def __init__(self,args):
		win32serviceutil.ServiceFramework.__init__(self,args)
		self._running = True

	def SvcDoRun(self):
		import servicemanager
		
		while self._running:
			servicemanager.LogInfoMsg("test python service - is alive and well")
			win32api.SleepEx(10000, True)
		servicemanager.LogInfoMsg("test python service - Stopped")

	def SvcStop(self):
		import servicemanager
		
		servicemanager.LogInfoMsg("test python service - Recieved stop signal")
		self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
		self._running = False




def ctrlHandler(ctrlType):
	return True

if __name__ == '__main__':
	## this lines sets it all up to run properly.
	win32api.SetConsoleCtrlHandler(ctrlHandler, True)
	win32serviceutil.HandleCommandLine(TestService)





